package com.css.fxfzaqbz.modules.data.controller;


import com.css.fxfzaqbz.base.response.RestResponse;
import com.css.fxfzaqbz.modules.data.entity.DisposeExport;
import com.css.fxfzaqbz.modules.data.entity.DisposeManager;
import com.css.fxfzaqbz.modules.data.service.DisposeExportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/fxfzaqbz/data")
@Slf4j
public class DisposeExportController {

    @Resource
    DisposeExportService disposeExportService;

    /**
     * 保存处置要点分析
     *
     * @param disposeExports 处置要点分析List
     * @return
     */
    @PostMapping("/saveDisposeExport")
    public RestResponse saveDisposeExport(@RequestBody List<DisposeExport> disposeExports) {
        RestResponse restResponse = null;
        try {
            restResponse = RestResponse.succeed(disposeExportService.saveDisposeExport(disposeExports));
        } catch (Exception e) {
            log.error("新增处置要点结论失败", e);
            restResponse = RestResponse.fail("新增处置要点结论失败!");
        }
        return restResponse;
    }


    /**
     * 根据 主键 id 查找处置分析数据
     *
     * @param id 主键 id
     * @return 查找数据
     */
    @GetMapping("/getDisposeExport/{id}")
    public RestResponse<DisposeManager> getDisposeExport(@PathVariable("id") String id) {
        RestResponse restResponse = null;
        try {
            restResponse = RestResponse.succeed(disposeExportService.getDisposeExport(id));
        } catch (Exception e) {
            log.error("获取处置要点结论失败!", e);
            restResponse = RestResponse.fail("获取处置要点结论失败!");
        }
        return restResponse;
    }
    

    /**
     * 根据 id 删除活动与处置要点
     *
     * @param ids 处置分析 id
     * @return
     */
    @PatchMapping("/delDisposeExport/{ids}")
    public RestResponse delDisposeExport(@PathVariable("ids") List<String> ids) {
        RestResponse restResponse = null;
        try {
            disposeExportService.delDisposeExport(ids);
            restResponse = RestResponse.succeed();
        } catch (Exception e) {
            log.error("删除处置要点结论失败!", e);
            restResponse = RestResponse.fail("删除处置要点结论失败!");
        }
        return restResponse;
    }


}
